package com.gopay.common.cps.service.fund.impl;

import com.gopay.common.cps.service.fund.FundCpsGenOrder;
import com.gopay.common.domain.cust.CustCorpInfo;
import com.gopay.common.order.dao.CommonQueryDAO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author baiyunpeng
 * @2016年7月14日 下午3:36:05  www.gopay.com.cn Inc.All rights reserved.
 */
@Service("fundCpsGenOrder")
public class FundCpsGenOrderImpl implements FundCpsGenOrder {
    @Resource(name = "commonQueryDAO")
    private CommonQueryDAO commonQueryDAO;
    @Override
    public List<CustCorpInfo> queryAllFundCorp(Map paraMap) {
        List<CustCorpInfo> corpList=new ArrayList<CustCorpInfo>();
        StringBuilder sb = new StringBuilder();
        sb.append(" select corp.cust_id,corp.corp_name,corp.is_real_name_certify from CUST_CORP_INFO corp ,CUST_INFO_EXTEND_ITEM item where corp.cust_id= item.cust_id and item.item_key='fundOrgNo' ");

        if(paraMap !=null){
            if(paraMap.get("custId")!=null){
                sb.append(" and corp.cust_id=:custId");
            }
        }
        List<Object[]> rsList = commonQueryDAO.findBySql(sb.toString(),paraMap);

        for(Object[] obj : rsList){
            CustCorpInfo corp = new CustCorpInfo();
            corp.setCustId(obj[0].toString());
            corp.setIsRealNameCertify(obj[2].toString());
            corpList.add(corp);
        }
        return corpList;
    }
}
